package com.wry.wry_test.demo;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @Author: wangrongyi
 * @Date: 2025/1/7 9:21
 * @Description:
 */
public class DateDemo {


    public static void main(String[] args) {


        Instant instant = Instant.now();
        System.out.println(instant);
        System.out.println(instant.getEpochSecond());
        System.out.println(instant.getNano());
        System.out.println(System.currentTimeMillis());

        ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of("America/New_York"));
        System.out.println(zonedDateTime);
        // 格式化zonedDateTime输出
        System.out.println(zonedDateTime.toLocalDateTime());
        System.out.println(zonedDateTime.getZone());


        LocalDateTime localDateTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String formatDateTime = localDateTime.format(formatter);
        System.out.println(formatDateTime);


    }

}
